package com.xggstudio.crm.ui.mvp.p;
import android.util.Log;
import com.xggstudio.crm.api.APIServer;
import com.xggstudio.crm.ui.mvp.m.UserInfoBean;
import com.xggstudio.crm.ui.mvp.v.IMyself;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class P_myself {

    private IMyself myself;

    public P_myself(IMyself myself) {
        this.myself = myself;
    }

    public void getInfo(String token){

        if(token == null){
            Log.e("P_myself", "getInfo: token = null " );
            return;
        }

        APIServer.getInstence().getServer()
                .getInfo(token)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Subscriber<UserInfoBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(UserInfoBean baseResult) {

                        if(baseResult.getCode().equals("1")){

                            myself.setViewData(baseResult);

                        }else{

                        }

                    }
                });


    }
}
